package greedy.onClass.class2.exer04;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.next();
            int k = scanner.nextInt();
            String num = s;
            int cnt = 0;
            while (cnt < k) {
                boolean flag = false;
                for (int i = 0; i < s.length() - 1; i++) {
                    if (s.charAt(i) > s.charAt(i + 1)) { // 如果后面比前面小就删掉前面
                        cnt++;
                        s = s.substring(0, i) + s.substring(i + 1);
                        flag = true;
                        break;
                    }
                }
                if (!flag) { // 如果全都一样或全部递增，去除末尾
                    cnt++;
                    s = s.substring(0, s.length() - 1);
                }
            }

            int i = 0;
            for (int j = 0; j < num.length(); j++) {
                if (i < s.length() && s.charAt(i) == num.charAt(j)) { // 打印原始字符串中未被删除的字符
                    i++;
                } else {
                    if (cnt == 1) {
                        System.out.println(num.charAt(j));
                    } else {
                        System.out.print(num.charAt(j) + " ");
                        cnt--;
                    }
                }
            }
            System.out.println(s); // 打印剩余的字符串
        }
        scanner.close();
    }
}
